package com.jz.community.moduleshopping.integralGoods.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.basecomm.utils.BaseImageLoaderUtils;
import com.jz.community.basecomm.utils.CharacterUtils;
import com.jz.community.basecomm.utils.ConverterUtils;
import com.jz.community.basecomm.utils.RxTextTool;
import com.jz.community.moduleshopping.R;
import com.jz.community.moduleshopping.integralGoods.bean.IntegralGoodsInfo;

import java.util.List;

/**
 * Created by Tony.Fan on 2018/7/2 09:37
 */
public class IntegralGoodsAdapter extends BaseQuickAdapter<IntegralGoodsInfo.EmbeddedBeanXX.ContentBeanX, BaseViewHolder> {


    public IntegralGoodsAdapter(@Nullable List<IntegralGoodsInfo.EmbeddedBeanXX.ContentBeanX> data) {
        super(R.layout.module_shopping_integral_goods_item_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, IntegralGoodsInfo.EmbeddedBeanXX.ContentBeanX item) {
        showIntegralGoodsInfo(helper, item);
    }

    private void showIntegralGoodsInfo(BaseViewHolder helper, IntegralGoodsInfo.EmbeddedBeanXX.ContentBeanX item) {
        BaseImageLoaderUtils.getInstance().loadDefaltImage(mContext, helper.getView(R.id.integral_iv), item.getIcon());
        helper.setText(R.id.integral_name, item.getTitle());
        helper.setText(R.id.integral_tv, item.getSkuInfos().get(0).getDiscountPrice());
        helper.setText(R.id.integral_price, item.getTitle());
        RxTextTool.getBuilder("").append("¥" + CharacterUtils.roundByGoodPrice(ConverterUtils.toDouble(item.getSkuInfos().get(0).getPrice()))).setStrikethrough().into(helper.getView(R.id.integral_price));
        helper.addOnClickListener(R.id.integral_btn);
    }
}
